import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import SearchView from '@/views/SearchView.vue'
import NotFind from '@/views/NotFind.vue'

const routes = [
    // 路径重定向
    { path: '/', redirect: '/home' },

    // 路由跳转
    { path: '/home', component: HomeView },
    // { path: '/search', component: SearchView },
    { path: '/search/:key?', component: SearchView }, // 动态路由

    // 匹配不到的页面
    { path: '/:catchAll(.*)', component: NotFind },
]

const router = createRouter({
    // 配置路由模式 - 默认是hash模式，常用是history模式
    // history: createWebHashHistory(),
    history: createWebHistory(),
    routes
})

export default router